//
//  MCOrderDetailNoteView.swift
//  StoreManage
//
//  Created by MC on 2017/12/21.
//  Copyright © 2017年 MC. All rights reserved.
//

import UIKit

class MCOrderDetailNoteView: UIView {


    override init(frame: CGRect) {
        super.init(frame: frame)
        
        backgroundColor = UIColor.white
        
        self.addSubview(ticketHeadView)
        ticketHeadView.snp.remakeConstraints { (make) ->Void in
            make.left.equalTo(10)
            make.right.equalTo(-10)
            make.top.equalTo(0)
            make.height.equalTo(40)
        }
        
        self.addSubview(orderAmountHeadView)
        orderAmountHeadView.snp.remakeConstraints { (make) ->Void in
            make.left.equalTo(10)
            make.right.equalTo(-10)
            make.top.equalTo(ticketHeadView.snp.bottom)
            make.height.equalTo(40)
        }
        
        self.addSubview(invoiceHeadView)
        invoiceHeadView.snp.remakeConstraints { (make) ->Void in
            make.left.equalTo(10)
            make.right.equalTo(-10)
            make.top.equalTo(orderAmountHeadView.snp.bottom)
            make.height.equalTo(40)
        }
        
        
        self.addSubview(invoiceMoneyView)
        invoiceMoneyView.snp.remakeConstraints { (make) ->Void in
            make.left.equalTo(10)
            make.right.equalTo(-10)
            make.top.equalTo(invoiceHeadView.snp.bottom)
            make.height.equalTo(40)
        }
        
        
        self.addSubview(noteView)
        noteView.snp.remakeConstraints { (make) ->Void in
            make.left.equalTo(10)
            make.right.equalTo(-10)
            make.top.equalTo(invoiceMoneyView.snp.bottom)
            make.height.equalTo(40)
        }
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    lazy var ticketHeadView: MCOrderDetailNoteItemView = {
        let view = MCOrderDetailNoteItemView()
        view.nameLabel.text = "优惠券减免："
        view.detailLabel.text = "¥0"
        return view
    }()
    
    lazy var orderAmountHeadView: MCOrderDetailNoteItemView = {
        let view = MCOrderDetailNoteItemView()
        view.nameLabel.text = "订单总金额："
        view.detailLabel.text = "¥0"
        return view
    }()
    
    lazy var invoiceHeadView: MCOrderDetailNoteItemView = {
        let view = MCOrderDetailNoteItemView()
        view.nameLabel.text = "开票抬头："
        view.detailLabel.text = "上海公司"
        return view
    }()

    lazy var invoiceMoneyView: MCOrderDetailNoteItemView = {
        let view = MCOrderDetailNoteItemView()
        view.nameLabel.text = "开票金额："
        view.detailLabel.text = "¥666"
        return view
    }()

    lazy var noteView: MCOrderDetailNoteItemView = {
        let view = MCOrderDetailNoteItemView()
        view.nameLabel.text = "备注："
        view.detailLabel.text = "无"
        return view
    }()
}










class MCOrderDetailNoteItemView: UIView {
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        self.addSubview(lineView)
        lineView.snp.remakeConstraints { (make) ->Void in
            make.left.right.bottom.equalTo(0)
            make.height.equalTo(1)
        }
        
        self.addSubview(nameLabel)
        nameLabel.snp.remakeConstraints { (make) ->Void in
            make.centerY.equalTo(self)
            make.left.equalTo(0)
        }
        
        self.addSubview(detailLabel)
        detailLabel.snp.remakeConstraints { (make) ->Void in
            make.centerY.equalTo(self)
            make.right.equalTo(0)
            make.left.lessThanOrEqualTo(nameLabel.snp.right).offset(10)
        }
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    lazy var lineView: UIView = {
        let view = UIView()
        view.backgroundColor = UIColor.MCGray_light
        return view
    }()
    
    
    public lazy var nameLabel: UILabel = {
        let label = UILabel.init()
        label.font = MCFont(14)
        label.textColor = UIColor.black
        return label
    }()
    
    
    public lazy var detailLabel: UILabel = {
        let label = UILabel.init()
        label.font = MCFont(14)
        label.textColor = UIColor.black
        label.textAlignment = NSTextAlignment.right
        return label
    }()
}
